package com.example.springboot.redis.config;

import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @desc:手动注入bean,可以不用注入，使用springboot默认注入
 * @Author wangsh
 * @date 2018/6/14 22:06
 */
//@Configuration
public class RedisConfig {

	@Bean
	public RedisConnectionFactory getRedisConnectionFactory() {

		return new JedisConnectionFactory();
	}

	@Bean
	public RedisTemplate getRedisTemplate() {

		RedisTemplate redisTemplate = new RedisTemplate();
		redisTemplate.setConnectionFactory(getRedisConnectionFactory());

		return redisTemplate;
	}

}
